package io.github.siltal.examsystembackend.controller;

import io.github.siltal.examsystembackend.dto.*;
import io.github.siltal.examsystembackend.service.QuestionOptionService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/question_option")
public class QuestionOptionController {

    private final QuestionOptionService questionOptionService;

    public QuestionOptionController(QuestionOptionService questionOptionService) {
        this.questionOptionService = questionOptionService;
    }


    @GetMapping("/get_question_option")
    public ResponseEntity<?> getQuestionOption() {
        RandomQuestionOptionResponse res = questionOptionService.getRandomQuestionOption(10);
        return ResponseEntity.status(HttpStatus.OK).body(res);
    }

    @PostMapping("/exam_history_submit")
    public ResponseEntity<?> examHistorySubmit(@RequestBody ExamHistorySubmitRequest submitRequest) {
        ExamHistorySubmitResponse res = questionOptionService.examHistorySubmit(submitRequest);
        return ResponseEntity.status(HttpStatus.OK).body(res);
    }

    @PostMapping("/exam_history_fetch")
    public ResponseEntity<?> examHistoryFetch(@RequestBody ExamHistoryFetchRequest fetchRequest) {
        ExamHistoryFetchResponse res = questionOptionService.examHistoryFetch(fetchRequest);
        return ResponseEntity.status(HttpStatus.OK).body(res);
    }


}